package com.example.controller;

import com.example.pojo.Materials;
import com.example.pojo.PageBean;
import com.example.pojo.Production;
import com.example.pojo.Result;
import com.example.service.ProductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/production")
public class ProductionController {
    @Autowired
    private  ProductionService productionService;

    @GetMapping
    public Result selectAll(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize,
                            String name, @RequestParam(defaultValue = "0") int num){
        PageBean pageBean=productionService.page(page,pageSize,name,num);
        return Result.success(pageBean);
    }

    @GetMapping("/sel")
    public Result getID(){
        List<Production> productions = productionService.getAll();
        return Result.success(productions);
    }
    @PutMapping
    public Result update(@RequestBody Production production){
        productionService.update(production);
        return Result.success();
    }
}
